#include "process.h"
#include <string.h>
#include <unistd.h>

void process_v1()
{
    char buff[101];
    memset(buff,0,sizeof(buff));
    int cnt = 0;
    const char *lable="|/-\\";
    int len = strlen(lable);
    while(cnt <= 100)
    {
        printf("[%-100s][%d%%][%c]\r",buff,cnt,lable[cnt%len]);
        fflush(stdout);
        buff[cnt] = '=';
        cnt++;
        usleep(50000);
    }
    printf("\n");
}



void  Flushprocess(double total,double current)
{    
    char buff[101];
    memset(buff,0,sizeof(buff));
    const char *lable="|/-\\";
    static int cnt = 0;
    int len = strlen(lable);
    cnt %= len;
    int num = (int)(current * 100 / total);
    for(int i = 0 ; i < num; i ++)
    {
        buff[i] = '=';
    }
    double rate = current * 100 / total;
    printf("[%-100s][%.1f%%][%c]\r",buff,rate,lable[cnt]);
    fflush(stdout);
    cnt ++;
}
